//
//  SKLTableViewCell.m
//  XOWMSDK
//
//  Created by SKL on 2017/12/1.
//  Copyright © 2017年 SKL. All rights reserved.
//

#import "XOWMAccountCell.h"
#import "XOWMLabel.h"
#import "XOWMCustomButton.h"
@interface XOWMAccountCell()
@property (nonatomic, strong) XOWMLabel *accountLBL;
@property (nonatomic, strong) XOWMCustomButton *deleteBtn;
@end

@implementation XOWMAccountCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return self;
}

- (XOWMLabel *)accountLBL
{
    if (!_accountLBL)
    {
        _accountLBL = [[XOWMLabel alloc]init];
        _accountLBL.font = [UIFont systemFontOfSize:17 weight:UIFontWeightLight];
        [self addSubview:_accountLBL];
        _accountLBL.c_left.equal(self).with.coffset(10);
    }
    return _accountLBL;
}

- (XOWMCustomButton *)deleteBtn
{
    if (!_deleteBtn)
    {
        _deleteBtn = [[XOWMCustomButton alloc]initWithCustomIMG:@"cancel" bound:CGRectMake(0, 0, 20, 20)];
        [_deleteBtn addTarget:self action:@selector(yjd_actionForDeleteBtn) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:_deleteBtn];
        _deleteBtn.c_centerY.equal(self);
        _deleteBtn.c_right.equal(self).with.coffset(-5);
        _deleteBtn.c_size.equal(self.deleteBtn.bounds.size);
    }
    return _deleteBtn;
}

- (void)setAccount:(NSString *)account
{
    if (_account != account)
    {
        _account = account;
        self.deleteBtn.hidden = NO;
        self.accountLBL.text = _account;
        self.accountLBL.c_size.equal(self.accountLBL.bounds.size);
        self.accountLBL.c_centerY.equal(self);
    }
}

- (void)yjd_actionForDeleteBtn
{
    if (self.block)
    {
        UITableView *tableView = [self yjd_findTableview:self];
        NSIndexPath *index = [tableView indexPathForCell:self];
        self.block(index);
    }
}

- (id)yjd_findTableview:(UIView *)view
{
    if ([view.superview  isKindOfClass:[UITableView class]])  return view.superview;
    else  return [self yjd_findTableview:view.superview];
}
- (void)setSelected:(BOOL)selected
{
    [super setSelected:selected];
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}



- (void)sp_getUsersMostFollowerSuccess {
    NSLog(@"Get Info Success");
}
@end
